package com.fhz.mvvm.api

import androidx.lifecycle.LiveData
import com.fhz.loginmvvm.callback.ApiResponse
import com.fhz.loginmvvm.callback.LiveDataCallAdapterFactory
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.POST
import retrofit2.http.Query

/**
 * 时间:2023/3/28
 * @author Mr.Feng
 * 简述: 用依赖注入的方式提供接口
 */
object YaoServiceApi {

//    private val retrofit:Retrofit =  Retrofit.Builder()
//        .baseUrl(Cons.HOST)
//        .client(OkHttpClient().newBuilder()
//            .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)).build())
//        .addCallAdapterFactory(LiveDataCallAdapterFactory())
//        .addConverterFactory(GsonConverterFactory.create())
//        .build()
//
//    fun <T> create(clzss:Class<T>) : T = retrofit.create(clzss)

//    //简化写法
////    inline fun <reified T> create() :T = create(T::class.java)
//


//    @POST(Cons.LOGIN)
//    //Callback ->
//    fun login(@Query("username") username:String, @Query("password") password:String) : LiveData<ApiResponse<UserEntity>>
}